package leetcode_数与位._01数字的位操作;

/**
 * @author yzh
 * @data 2021/3/22 21:25
 * 2的幂
 * -x = ~x + 1
 * x & (-x) == x
 * x & (x - 1) == 0
 */
public class _231_2的幂 {
    public static void main(String[] args) {
        System.out.println(Math.log1p(2));
    }

    public boolean isPowerOfTwo(int n) {
        if (n == 0) return false;
        while (n % 2 == 0) {
            n /= 2;
        }
        return n == 1;
    }

    public boolean isPowerOfTwo_perfect01(int n) {
        if (n == 0) return false;
        return (n & (-n)) == n;
    }
}
